package controller.dialog;

import javafx.fxml.FXMLLoader;
import javafx.geometry.Rectangle2D;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.paint.Color;
import javafx.stage.Modality;
import javafx.stage.Screen;
import javafx.stage.Stage;
import javafx.stage.StageStyle;

/*
 * Mantem o message dialog estatica... 
 */
public class DialogMessage {
    private static DialogMessage intancia;
    private static Stage s;
    private Parent root;
    
    public DialogMessage() {
        try{
            Screen screen = Screen.getPrimary();
            Rectangle2D bounds = screen.getVisualBounds();
            root = FXMLLoader.load(getClass().getResource("/view/dialog/Message.fxml"));
            Scene scene = new Scene(root,Color.web("0xdfdfdfee"));
            s = new Stage(StageStyle.TRANSPARENT);
            s.setScene(scene);
            s.initModality(Modality.APPLICATION_MODAL);
        }catch(Exception e){}
    }

    public static DialogMessage getIntancia() {
        if (intancia == null) {
            intancia = new DialogMessage(); 
        }
        return intancia;
    }
    
    public void show(String message){
        Label l = (Label) root.lookup("#message");
        l.setText(message);
        s.show();
    }
    
    public void close(){
        s.close();
    }
}
